/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package application.dao;

import application.model.Blacklist;

import java.util.ArrayList;

import org.hibernate.SessionFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;

/**
 *
 * @author aa6345
 */
@Repository("blacklistDao")
public class BlacklistDaoImpl implements BlacklistDao{
    @Autowired
    private SessionFactory sessionFactory;

    // To get list of all
    @SuppressWarnings("unchecked")
    public List<Blacklist> listAllBlacklistTerms() {
        List<Blacklist> selectedEntityAccomps = new ArrayList<Blacklist>();        

            String searchQuery = "select `bl`.`id` as id,"
                    + "`bl`.`term` as term "
                    + "from blacklist bl ;";            

            selectedEntityAccomps = sessionFactory.getCurrentSession().createSQLQuery(searchQuery).addEntity(Blacklist.class).list();

        return selectedEntityAccomps;
    }
}
